package org.activequant.container.report;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Simple Report holds key-value objects.
 * These key-value objects have to be created in some place,
 * preferably in some ReportGenerator. The actual rendering
 * has to be done somewhere else. <br/>
 * The reportValues is initiated upon instantiation. <br/>
 * Example of use: report.getReportValues().put("some key","some value");<br/>
 * An IReport implementation. Holds the following associated variable:
 * <ul>
 * <li>reportValues(Map&lt;String,Object&gt;)</li>
 * </ul>
 * <br/>
 * <b>History:</b><br/>
 *  - [05.10.2009] Branched from AccountReport (Ulrich Staudinger) <br/>
 *
 *  @author Ulrich Staudinger
 */
public class SimpleReport implements IReport {
	/**
	 * private Map&lt;String, Object&gt; reportValues = new HashMap&lt;String, Object&gt;();
	 */
    private Map<String, Object> reportValues = new HashMap<String, Object>();

    /**
     * simple getter to fetch list of keys<br/>
     * returns a String[] holding the keys of the associated reportValues(Map&lt;String,Object&gt;) in alphabetic order
     * @return string array with all keys in alphabetic order. 
     */
	public String[] getKeys()
	{
		String[] keys = new String[reportValues.size()];
		List<String> keyList = new ArrayList<String>();
		for(String s : reportValues.keySet())
			keyList.add(s);
		Collections.sort(keyList);
		for(int i=0;i<keyList.size();i++)
			keys[i] = keyList.get(i);
		return keys; 
	}
	

    /**
     * plain getter.<br/>
     * returns the associated reportValues(Map&lt;String,Object&gt;)
     * @return the report values.
     */
    public Map<String, Object> getReportValues() {
        return reportValues;
    }

    /**
     * plain setter.<br/>
     * sets the associated reportValues(Map&lt;String,Object&gt;) with the given reportValues(Map&lt;String,Object&gt;)
     * @param reportValues the report values generated.
     */
    public void setReportValues(Map<String, Object> reportValues) {
        this.reportValues = reportValues;
    }

   
}